package com.kingsalert.kingsalert.util;

import android.provider.Settings;
import android.text.TextUtils;

import com.kingsalert.kingsalert.base.BaseApplication;
import com.kingsalert.kingsalert.config.Constant;

import org.jetbrains.annotations.NotNull;


public class DecUtil {

    private static class InnerDeviceHelper {
        private static final DecUtil instance = new DecUtil();
    }

    public static DecUtil getInstance() {
        return InnerDeviceHelper.instance;
    }

    @NotNull
    public static String getPackageName() {
        String pckName = BaseApplication.getInstant().getPackageName();
        if (TextUtils.isEmpty(pckName)) {
            pckName = Constant.PACKAGE_NAME;
        }
        return pckName;
    }

    @NotNull
    public String getAndroidID() {
        String androidID = Settings.System.getString(BaseApplication.getInstant().getContentResolver(), Settings.Secure.ANDROID_ID);
        if (TextUtils.isEmpty(androidID)) {
            return System.currentTimeMillis() + "";
        }
        if (androidID.contains("00000000")) {
            return System.currentTimeMillis() + "";
        }
        return androidID;
    }

}
